<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <body>
        <ui:composition template="./../template.xhtml">
            <ui:define name="meta">
                <c:if test="${user != null}">
                    <c:if test="${user.isAdmin == false}">
                        <meta http-equiv="refresh" content="0; URL=#{facesContext.externalContext.requestContextPath}/faces/403error.xhtml" />
                    </c:if>
                </c:if>
                <c:if test="${user == null}">
                    <meta http-equiv="refresh" content="0; URL=#{facesContext.externalContext.requestContextPath}/faces/login.xhtml" />
                </c:if>
            </ui:define>
            <ui:define name="title">
                Add Winner Page
            </ui:define>
            <ui:define name="content">
                <h:form>
                    <p:panel header="Create New Winner " style="text-align: center;width: 100%">
                        <p:panelGrid>
                            <p:row>
                                <p:column>
                                    <h4 class="art-postheader">
                                        Choose Event :*
                                    </h4>
                                </p:column>
                                <p:column>
                                    <h4 class="art-postheader">
                                        <p:selectOneMenu   id="somEvent" value="#{winnerController.eventID}"   effect="fade" style="width: 200px"  >
                                            <f:selectItem itemLabel=" Select Event " itemValue="0" />
                                            <f:selectItems value="#{winnerController.listEvent}" />
                                            <p:ajax update="somWinner"
                                                    listener="#{winnerController.handleEventChange}" />
                                        </p:selectOneMenu>
                                    </h4>
                                </p:column>
                            </p:row>
                            <p:row>
                                <p:column>
                                    <h4 class="art-postheader">
                                        Choose Winner :*
                                    </h4>
                                </p:column>
                                <p:column>
                                    <h4 class="art-postheader">
                                        <p:selectOneMenu   id="somWinner" value="#{winnerController.playerID}" effect="fade" style="width: 200px" >
                                            <f:selectItem itemLabel=" Select Player " itemValue="0" />
                                            <f:selectItems value="#{winnerController.listWinnerTemp}" />
                                        </p:selectOneMenu>
                                    </h4>
                                </p:column>
                            </p:row>
                            <p:row>
                                <p:column>
                                    <h4 class="art-postheader">
                                        Prize :
                                    </h4>
                                </p:column>
                                <p:column>
                                    <h4 class="art-postheader">
                                        <p:inputTextarea value="#{winnerController.newPrize}" autoResize="false"
                                                         styleClass="art-blockcontent-body" style="width: 180px"  maxlength="300"
                                                         requiredMessage="Length of Prize must from 10 to 300 characters">
                                        </p:inputTextarea>
                                    </h4>
                                </p:column>
                            </p:row>
                            <p:row>
                                <p:column>
                                </p:column>
                                <p:column>    
                                    <p:commandButton image="ui-icon ui-icon-pencil" action="#{winnerController.createEvent}" value="Submit" ajax="false" style="width: 80px; height: 30px"/>
                                    <p:commandButton value="Cancel" immediate="true" action="#{winnerController.cancel}" style="width: 80px; height: 30px"/>
                                </p:column>
                            </p:row>
                        </p:panelGrid>
                    </p:panel>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
